
package com.lelv.business.travelInfo.dao;

import com.lelv.business.travelInfo.model.TravelArticle;
import com.lelv.framework.dao.BaseDao;
import com.lelv.framework.plugin.Page;

public class TravelArticleDaoImpl extends BaseDao<TravelArticle> implements ITravelArticleDao {

	/*
	 * 查询旅游信息
	 * @see com.lelv.business.travelInfo.dao.ITravelArticleDao#getTravelArticleList(com.lelv.framework.plugin.Page)
	 */
	@Override
	public Page getTravelArticleList(Page page) {
		// TODO Auto-generated method stub

		String hql = "from TravelArticle ta order by ta.createTime desc";

		return this.getPageByHql(hql, page);
	}

	/*
	 * 通过ID查询旅游信息
	 * @see com.lelv.business.travelInfo.dao.ITravelArticleDao#findTravelArticleById(java.lang.Long)
	 */
	@Override
	public TravelArticle findTravelArticleById(Long id) {
		// TODO Auto-generated method stub
		return this.get(id);
	}

	/*
	 * 更新旅游信息
	 * @see com.lelv.business.travelInfo.dao.ITravelArticleDao#updateTravelArticle(com.lelv.business.travelInfo.model.TravelArticle)
	 */
	@Override
	public void updateTravelArticle(TravelArticle ta) {
		// TODO Auto-generated method stub
		this.saveOrUpdate(ta);
	}

	/*
	 * 删除旅游信息
	 * @see com.lelv.business.travelInfo.dao.ITravelArticleDao#deleteTravelArticle(java.lang.Long)
	 */
	@Override
	public void deleteTravelArticle(Long id) {
		// TODO Auto-generated method stub
		this.delete(id);
	}

	@Override
	public void addTravelArticle(TravelArticle ta) {
		// TODO Auto-generated method stub
		this.save(ta);
	}

	/*
	 * 通过操作者ID查询旅游信息，权限控制
	 * @see com.lelv.business.travelInfo.dao.ITravelArticleDao#getTravelArticleList(com.lelv.framework.plugin.Page, java.lang.Long)
	 */
	@Override
	public Page getTravelArticleList(Page page, Long creatorId) {
		// TODO Auto-generated method stub
		String hql = "from TravelArticle ta where ta.creatorId ="+creatorId+" order by ta.createTime desc";

		return this.getPageByHql(hql, page);
	}

}
